import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { mars3dPlugin } from 'vite-plugin-mars3d'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), mars3dPlugin(), UnoCSS(), vueSetupExtend()],
  server: {
    host: '0.0.0.0',
    // headers: {
    //   'Access-Control-Allow-Origin': '*'
    // },
    // proxy: {
    //   // 选项写法
    //   '/api': {
    //     target: 'http://192.168.2.119:8000/',
    //     changeOrigin: true,
    //     rewrite: (path) => path.replace(/^\/api/, '')
    //   }
    // },
    cors: true
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
